use serde::{Deserialize, Serialize};

pub type DeviceIdNum = u32;

#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
pub struct DeviceId(pub DeviceIdNum);

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct DeviceName(pub String);

impl DeviceName {
    pub fn is_valid(&self) -> bool {
        !self.0.is_empty()
    }
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Device {
    pub id: DeviceId,
    #[serde(flatten)]
    pub info: DeviceInfo,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct DeviceInfo {
    pub name: DeviceName,
    pub certificate: String,
    pub enabled: bool,
}
